
package org.amos.upms.modules.system.service;

import com.baomidou.mybatisplus.extension.service.IService;
import org.amos.api.upms.dto.DictDetailDTO;
import org.amos.core.basic.annotation.CacheBatchEvict;
import org.amos.upms.modules.system.entity.DictDetail;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;

import java.util.List;
import java.util.Set;

import static org.amos.upms.constant.SysCacheConstant.SYS_DICT_KEY;

/**
 * <p>
 * 字典具体数据详情 服务类
 * </p>
 *
 * @author CodeGenerator
 * @since 2020-12-20
 */
public interface IDictDetailService extends IService<DictDetail> {

    DictDetail getOne(String code, String key);
    /**
     * 通过code获取字典信息
     *
     * @param dto
     * @return
     */
    @Cacheable(value = SYS_DICT_KEY, key = "#dto.dictCode", condition = "#dto.dictCode != null")
    List<DictDetail> selectList(DictDetailDTO dto);

    /**
     * 更新字典
     *
     * @param dto
     * @return
     */
    @CacheEvict(value = SYS_DICT_KEY, key = "#dto.dictCode", condition = "#dto.dictCode != null")
    Boolean saveOrUpdateDict(DictDetailDTO dto);

    /**
     * 根据ID删除字典信息
     *
     * @param ids
     * @return
     */
    Boolean remove(Set<Long> ids);

    /**
     * 根据字典ID删除详情信息
     *
     * @param ids
     * @return
     */
    Boolean removeByDictId(Set<Long> ids);

    /**
     * 删除code后缀缓存
     *
     * @param codes
     * @return
     */
    @CacheBatchEvict(cacheNames = SYS_DICT_KEY, key = "#codes")
    Boolean removeByCodes(Set<String> codes);
}
